<template>
    <!--
        PDF阅读器
        body-class="modalStyle" 表示样式
        size="lg" 表示模态窗口大小 xl,lg,sm,full
        hide-footer 表示隐藏底部按钮
        hide-header 表示隐藏头部内容
        no-close-on-backdrop 表示鼠标点击背景不可关闭
        hide-header-close 表示隐藏头部关闭按钮
        centered 居中
        ok-title=“确定” 
        cancel-title=取消
        @ok="handleOk" 
        @cancel="handleCancel"
        scrollable 滚动条
        hide-backdrop 隐藏背景
        wrapClassName="ant-modal-cust-warp" 
        style="top:5%;height: 85%;overflow-y: hidden" 样式
    -->
    <b-modal ref="my-modal" title="PDF阅读器" size="xl" scrollable hide-footer no-close-on-backdrop>
        <div class="d-block text-center">
            <iframe width="100%" :height="iframeHeight" scrolling="no" :src="pdfPath"></iframe>
        </div>
        <template slot="modal-footer">
            <!--自定义按钮-->
            <!-- <button type="button" class="btn btn-light-danger font-weight-bold mr-2" block @click="hideModal">
                <i class="icon-xl fa fa-times"></i>取消
            </button> 
            <button type="button" class="btn btn-light-success font-weight-bold mr-2" @click="doSelect">
                <i class="icon-xl fas fa-save"></i> 确定
            </button> -->
        </template>
    </b-modal>
</template>
<script>
  import apiUtil from "@/core/util/apiUtil.js"; 
    export default {
        data() {
            return {
                blobUrl:"",
                pdfPath:"",
                iframeHeight:window.innerHeight-170,
            }
        },
        mounted() {
            this.$nextTick(() => {
                this.iframeHeight = window.innerHeight-170;           
                // 监听窗口大小变化
                window.onresize = () => {
                    this.iframeHeight = window.innerHeight-170;
                }
            })
        },
        methods: {              
            showModal(blobUrl) {
                this.pdfPath = process.env.BASE_URL + "pdfjs/web/viewer.html?file="+blobUrl
                this.$refs['my-modal'].show();
            },
            hideModal() {
                this.$refs['my-modal'].hide()
            },
            toggleModal() {
                this.$refs['my-modal'].toggle('#toggle-btn')
            },
        }
    }
</script>